package com.uchedao.seller.widget;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.widget.TextView;

import com.uchedao.seller.R;

/**
 * 自定义弹窗视图--单例模式
 */
public class DialogCustomProgress extends Dialog {

    private static DialogCustomProgress mDialogCustomProgress = null;

    private DialogCustomProgress(Context context) {
        super(context);
    }

    private DialogCustomProgress(Context context, int theme) {

        super(context, theme);

    }

    public static DialogCustomProgress createDialog(Context context) {
        if (mDialogCustomProgress == null) {
            mDialogCustomProgress = new DialogCustomProgress(context,
                    R.style.CustomProgressDialog);
            mDialogCustomProgress.setContentView(R.layout.dialog_progress);
            mDialogCustomProgress.getWindow().getAttributes().gravity = Gravity.CENTER;
        }
        return mDialogCustomProgress;

    }

    @Override
    public void show() {
        super.show();
    }

    public DialogCustomProgress setMessage(String strMessage) {
        TextView tvMsg = (TextView) mDialogCustomProgress
                .findViewById(R.id.id_tv_loadingmsg);
        if (tvMsg != null) {
            tvMsg.setText(strMessage);
        }
        return mDialogCustomProgress;

    }

}
